<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>配送关系管理 设置配送关系（中心）</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>设置配送关系</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">采购目录管理</a></li>
            <li class="active"><a href="#">配送关系管理</a></li>
            <li class="active"><a href="#">设置配送关系</a></li>
        </ol>
    </section>
    <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">  
                    <div class="form-group form-group-xs">
                        <label>配送区域：</label>
                        <select id="area1" name="area1" class="form-control"></select>
                        <select id="area2" name="area2" class="form-control"></select>
                        <select id="area3" name="area3" class="form-control"></select>
                    </div>
                </div>                
            </div>
        </div>
        
        
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">  
                <div class="form-group form-group-xs">
                        <label>企业编码：</label>
                        <input class="form-control" type="text" id="compCode" name="compCode" placeholder="企业编码"  />
                    </div>              
                    <div class="form-group form-group-xs">
                        <label>企业名称：</label>
                        <input class="form-control" type="text" id="compName" name="compName" placeholder="企业名称"  />
                    </div>
                    
                    <button type="button" onclick="gridSerch();" class="btn btn-success btn-xs">查&nbsp;询</button>
                </div>                
            </div>
        </div>
<div style="margin-top: 5px;"></div>
    <table class="jqgrid" id="list4"></table>
<div style="margin-top: 10px;"></div>
<div id="prowed2"></div>
<div class=" box box-warning bottongroup" id="bottongroup">
            <label onclick="setDel();" class="btn btn-default btn-sm">设置</label>
            <label  onclick="window.location.href='${ctx}/baseDel/toBaseDelByCentreListSee.html'"   class="btn btn-default btn-sm" >返 回</label>
        </div>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
function setDel(){
    var rowIds = $("#list4").jqGrid("getGridParam", "selarrrow") || [];
    if (rowIds.length <= 0) {
        $.HN.message.alert("请选择要操作的行！", "消息", "error");
        return;
    }
    
    var area = $.trim($("#area3").val());
    if (area == ""){
        area = $.trim($("#area2").val());
        if (area == ""){
            area = $.trim($("#area1").val());
        }
    }
    if (area == ""){
        $.HN.message.alert("请选择配送区域！", "消息", "error");
        return;
    }
    var goodsCode = '${goodsCode}';
    var list = [];
    for (var i=0; i<rowIds.length; i++) {
        rowId = rowIds[i];
        //var rowdata = $("#list4").jqGrid('getRowData', rowIds[i]);
        list.push({"goodsCode":goodsCode,
            "areaCode":area,
            "delCompId":rowId});
    }
    $.post("${pageContext.request.contextPath}/baseDel/setDelByArea.html", {
        "array" : json.jsonToString(list)
        }, function(result) {
            if (result.success) {
                $.HN.message.alert("设置成功！", "消息", "success");
                window.location.href="${ctx}/baseDel/toBaseDelByCentreListSee.html";
            } else {
                $.HN.message.alert("设置失败！", "消息", "error");
            }
        }, "json")
}
$(document).ready(function (){
    jQuery("#list4").jqGrid({
        url: "${ctx}/baseDel/getBaseDelByCentreListManage.html",
        mtype: "POST",
        datatype: "json",
        autowidth: true,
        shrinkToFit: true,
        height: 250,
        colNames:['id','企业编码','企业名称','注册地','企业注册类型','组织机构代码'],
        colModel:[
            {name:'compId',index:'compId',key:true,hidden:true,width:100,align:"center", sorttype:false},
            {name:'compCode',index:'compCode',width:100,align:"center", sorttype:false},
            {name:'compName',index:'compName',width:150},
            {name:'areaId',index:'areaId',width:80, align:"left",sorttype:false},
            {name:'compRegId',index:'compRegId',width:80, align:"left",sorttype:false},
            {name:'orgCode',index:'orgCode',width:60,align:"center", sorttype:false}
        ],
        gridComplete: function(){
            
        },
         rowNum: 10,
         rowList: [10, 20, 30],
         rownumbers: true,
         multiselect: true,
         pager: "#prowed2",
         viewrecords: true,
         caption: "设置配送关系列表",
         jsonReader: {
             repeatitems: false,
             id: "ids"
         }
        
    });
    $("#area1").HNSelect({
        url: "${pageContext.request.contextPath}/selectController/getArea.html", data: { ID: '000000' }, defaultText: "<option value=''>请选择</option>",
        func: function () {
            $("#area2").HNSelect({
                parent_selector: "#area1", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                func: function () {
                    $("#area3").HNSelect({
                        parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                    });
                }
            });
        }
    });
})

function gridSerch(){
    var compCode = $.trim($("#compCode").val());
    var compName = $.trim($("#compName").val());
    $("#list4").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"compCode":compCode,
                "compName":compName}
    }).trigger("reloadGrid"); //重新载入  
}



     function edit(cl){
         window.location.href="delRelDrugQuery.jsp";
     }
    function save(cl){
         alert("保存信息");
    }
    jQuery("#list4").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
    function hosAdd(){
        window.location.href="hospEdit.jsp";
    }

    function hospAuditDetail(){
        alert("显示信息详情");
        //window.location.href = "hospAuditDetail.jsp";
    }
    function refash(){
        location.reload();
    }
    function gridReload(){
        var area=document.getElementById("area").value;
        alert("查询地区名："+area);
    }
    function goJsp(n1){
        var opt ={
                url:"../../jsp/price/priceChangeExeDetailGrid.jsp",
                title:"newwindow",
style:{height:400,width:890,top:200,left:270}
        };
        $.HN.dialog.open(opt);
    }
     function lookYPnumber(ypnumber){
            var opt={
                    url:"../../jsp/price/priceChangeDetailYP.jsp",
                    title:"newwindow",
    style:{height:400,width:890,top:200,left:270}
            };
            $.HN.dialog.open(opt);
        }
        
</script>
</body>
</html>